import request from '@/utils/request';
export async function query(): Promise<any> {
  return request('/api/users');
}

export async function queryCurrent(): Promise<any> {
  return request('/api/user');
}

export async function queryNotices(): Promise<any> {
  return request('/api/notices');
}

//酒类接口汇总
export async function commodityAdd(params: any): Promise<any> {
  return request('/api/wine', {
    method: 'POST',
    data: params,
  });
}

export async function commodityEdit(params: any): Promise<any> {
  return request('/api/wine', {
    method: 'PUT',
    data: params,
  });
}

export async function commodityDelete(params: any): Promise<any> {
  return request('/api/wine', {
    method: 'DELETE',
    params: params,
  });
}

export async function commodityList(params: any): Promise<any> {
  return request('/api/wine/list', {
    params: params,
  });
}

export async function commodityQuery(params: any): Promise<any> {
  return request('/api/wine/query', {
    method: 'GET',
    params: params,
  });
}

export async function commodityDown(): Promise<any> {
  return request('/api/wine/downTemplate', {
    headers: {
      Accept: 'application/octet-stream',
    },
    responseType: 'arrayBuffer',
  });
}

export async function commodityUpload(formData: any): Promise<any> {
  return request('/api/wine/upload', {
    method: 'POST',
    // headers: {
    //   'Content-Type': 'multipart/form-data',
    // },
    // responseType:'json',
    data: formData,
  });
}
export async function commodityType(): Promise<any> {
  return request('/api/wine/type');
}

export async function commodityUtil(params: any): Promise<any> {
  return request('/api/wine/units', {
    method: 'GET',
    params: params,
  });
}
/**
 * 销售人员接口汇总
 */

//新增
export async function soldAdd(params: any): Promise<any> {
  return request('/api/staff', {
    method: 'POST',
    data: params,
  });
}

//修改
export async function soldEdit(params: any): Promise<any> {
  return request('/api/staff', {
    method: 'PUT',
    data: params,
  });
}
//删除
export async function soldDelete(params: any): Promise<any> {
  return request('/api/staff', {
    method: 'DELETE',
    params: params,
  });
}
//人员表
export async function soldList(params: any): Promise<any> {
  return request('/api/staffs', {
    method: 'GET',
    params: params,
  });
}
//根据输入字符检索(下拉框)
export async function soldSearch(params: any): Promise<any> {
  return request('/api/staff/query', {
    method: 'GET',
    params: params,
  });
}

/*
 * 订单接口汇总
 */
// 1. 查询订单历史表
export async function orderList(ordertype: string, params: any): Promise<any> {
  return request(`/api/${ordertype}`, {
    method: 'GET',
    params: params,
  });
}

// 2. 订单历史表导出
export async function orderDown(params: any): Promise<any> {
  return request('/api/order/down', {
    method: 'GET',
    params: params,
    headers: {
      Accept: 'application/octet-stream',
    },
    responseType: 'arrayBuffer',
  });
}
// 3. 保存（买入和售出）、修改 订单
export async function orderBuy(params: any): Promise<any> {
  return request('/api/order', {
    method: 'POST',
    data: params,
  });
}

// 编辑修改
export async function orderEdit(params: any): Promise<any> {
  return request('/api/order', {
    method: 'PUT',
    data: params,
  });
}

// 4. 无效订单（删除）
export async function orderDelete(params: any): Promise<any> {
  return request('/api/order', {
    method: 'Delete',
    params: params,
  });
}
//5.结算
export async function orderSettlement(params: any): Promise<any> {
  return request('/api/order/settlement', {
    method: 'Put',
    params: params,
  });
}

//6.生成利润
// PUT /api/order/profit
export async function orderProfit(params: any): Promise<any> {
  return request('/api/order/profit', {
    method: 'Put',
    params: params,
  });
}
